/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author yolan
 */
public class Siswa {

    private String nama;
    private String alamat;
    private String asalsekolah;
    private String tanggallahir;
    private String jeniskelamin;
    private String agama;
    private int nis;
    private String nem;
    private String koneksi = "tomcat";
    private String username = "root";
    private String password = "";
    private Connection con = null;
    koneksi conn;
    private Statement stmt = null;
    private ResultSet rs = null;
    private DatabaseMetaData dmd;
    private ResultSetMetaData rsmd;
    public ArrayList<rangking> RANK;

    public Siswa() {
        conn = new koneksi();
        RANK = new ArrayList<rangking>();
    }

    /**
     * @return the nama
     */
    public String getNama() {
        return nama;
    }

    /**
     * @param nama the nama to set
     */
    public void setNama(String nama) {
        this.nama = nama;
    }

    /**
     * @return the NIS
     */
    public int getnis() {
        return nis;
    }

    /**
     * @param NIS the NIS to set
     */
    public void setnis(int nis) {
        this.nis = nis;
    }

    /**
     * @return the alamat
     */
    public String getAlamat() {
        return alamat;
    }

    /**
     * @param alamat the alamat to set
     */
    public void setAlamat(String alamat) {
        this.alamat = alamat;
    }

    /**
     * @return the tanggallahir
     */
    public String getTanggallahir() {
        return tanggallahir;
    }

    /**
     * @param tanggallahir the tanggallahir to set
     */
    public void setTanggallahir(String tanggallahir) {
        this.tanggallahir = tanggallahir;
    }

    /**
     * @return the NEM
     */
    public String getnem() {
        return nem;
    }

    /**
     * @param NEM the NEM to set
     */
    public void setnem(String nem) {
        this.nem = nem;
    }

    /**
     * @return the jeniskelamin
     */
    public String getJeniskelamin() {
        return jeniskelamin;
    }

    /**
     * @param jeniskelamin the jeniskelamin to set
     */
    public void setJeniskelamin(String jeniskelamin) {
        this.jeniskelamin = jeniskelamin;
    }

    /**
     * @return the agama
     */
    public String getAgama() {
        return agama;
    }

    /**
     * @param agama the agama to set
     */
    public void setAgama(String agama) {
        this.agama = agama;
    }

    /**
     * @return the asalsekolah
     */
    public String getAsalsekolah() {
        return asalsekolah;
    }

    /**
     * @param asalsekolah the asalsekolah to set
     */
    public void setAsalsekolah(String asalsekolah) {
        this.asalsekolah = asalsekolah;
    }

    public void queryname() {
        try {
            String query2 = "select * from pendaftaran order by nem desc";

            java.sql.Statement statement = conn.getConnection().createStatement();
            java.sql.ResultSet result2 = statement.executeQuery(query2);
            String temp = "";
            while (result2.next()) {
                temp = result2.getString("NIS");
                setRangking(temp);
            }
            statement.close();
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
    }

//    public static void main(String[] args) {
//        Siswa s = new Siswa();
//        s.queryname();
//        s.showrangking();
//    }

    public void setRangking(String nis) {
        RANK.add(new rangking(nis));

    }

    public ArrayList getRangking() {
        return RANK;
    }

//    public void showrangking() {
//        for (int i = 0; i < RANK.size(); i++) {
//            System.out.println("NIS: " + RANK.get(i).getNis());
//        }
//    }
}
